//
//  CocoaHotkeysAppDelegate.m
//  CocoaHotkeys
//
//  Created by Matthias Plappert on 07.09.09.
//  Copyright 2009 phapswebsolutions. All rights reserved.
//

#import "CocoaHotkeysAppDelegate.h"

#import "PWHotkeyCenter.h"
#import "PWHotkey.h"

@implementation CocoaHotkeysAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
	// Register for notifications
	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveHotkeyCommand:) name:PWHotkeyNotification object:nil];
	
	// Get center and create hotkey1 + hotkey2
	PWHotkeyCenter *center = [PWHotkeyCenter mainCenter];
	PWHotkey *hotkey1 = [[PWHotkey alloc] initWithIdentifier:@"myFirstHotkey" flags:PWHotkeyCommandFlag + PWHotkeyOptionFlag key:30]; // 30 = +
	PWHotkey *hotkey2 = [[PWHotkey alloc] initWithIdentifier:@"mySecondHotkey" flags:PWHotkeyCommandFlag + PWHotkeyControlFlag key:49]; // 49 = space
	
	// Register hotkeys
	[center registerHotkey:hotkey1 error:nil];
	[center registerHotkey:hotkey2 error:nil];
	
	// Release hotkeys
	[hotkey1 release];
	[hotkey2 release];
}

- (void)didReceiveHotkeyCommand:(NSNotification *)notification
{
	// Do some ultracool stuff with your system-wide hotkeys
	NSLog(@"didReceiveHotkeyCommand with notification %@ and hotkey %@", notification, [notification object]);
}

@end
